<?php

namespace Admin\Controller;
use Admin\Builder\AdminConfigBuilder;

class PatentController  extends AdminController {
    public function index(){
    	$model	=	M('TbPatent');
        $patent = I('patentname', '', 'text');
        $map['status'] = array('egt', 0);
        $map['cID'] = UID;
        if ($patent !== '') {
            $map['patent'] = array('like', '%' . (string)$patent . '%');
        }
        
        //int_to_string($list,array('status'=>array(1=>'未通过审核',0=>'待审核',2=>'实习中',3=>'实习结束')));              //数字转为字符串
        $list = $this->lists($model, $map);
        $this->assign('_list', $list);
        
        $this->display();
    }
    
	public function add(){
		$this->display('edit');
	}
	
	public function edit(){
		$id=I('id');
		$model	=	M('TbPatent');
		$data=$model->find($id);
		$this->assign('data', $data);
		$this->display('edit');
	}
	
	public function save(){
		$model	=	M('TbPatent');
		$patent	=	$model->create();
		if(empty($patent['id'])){
			$patent['cID']=UID;
			$model->add($patent);
			$this->success("专利添加成功！",U('index'));
		}else {
			$model->save($patent);
			$this->success("专利修改成功！",U('index'));
		}
	}
	public function del(){
		$map['id']	=   I('id');	
		$this->delete('TbPatent',$map,array('success' => '专利删除成功！', 'error' => '专利删除失败！'));
	}
// 	public function edit(){
// 		$builder = new AdminConfigBuilder();
// 		$data = $builder->handleConfig();
// 		$builder->keyMultiImage('', '', '');

// 		$builder->display();
// 	}
	
}